
import {getByRegionName,getListByParentId} from '@/api/admin/region'
var baseUrl='/admin/region/parentId'

var regionCode=(rule,value,callback)=>{
  const v=value
  getByRegionName(value).then(response =>{
    const result = response.data.data
    console.log(result.regionName)
  })
}



var regionName = (rule, value, callback) => {
    let userNamereg=/^\S+$/
    if(!userNamereg.test(value)){
      callback(new Error('不允许有空格'))
    }else{
      getByRegionName(value).then(response => {
        callback();
      }).catch(()=>{
        callback(new Error('请输入正确地址'))
      })
    }

};



export const tableOption = {
  "border": true,
  "index": true,
  "indexLabel": "序号",
  "stripe": true,
  "menuAlign": "center",
  "align": "center",
  refreshBtn: true,
  showClomnuBtn: true,
  searchSize: 'mini',
  addBtn: false,
  editBtn: true,
  viewBtn: true,
  "column": [{
      "type": "input",
      "label": "id",
      "prop": "id",
      hide: true,
      editDisplay: false
    },	  {
      "type": "input",
      "label": "政府名称",
      "prop": "governmentName",
      search: true,
      rules: [{
        required: true,
        message: '请输入政府名称',
        trigger: 'blur'
      }]
    },	  {
      "type": "select",
      "label": "省编号",
      "prop": "provinceCode",
      editDisplay: false,

    },	  {
      "type": "select",
      "label": "省名称",
      "prop": "province",
      search: true,
      rules: [{
        required: true,
        message: '请输入正确的省级名称',
        trigger: 'blur'
      },
      {validator: regionName, trigger: 'blur'}],
      props: {
        label: 'regionName',
        value: 'regionName'
      },

      dicUrl:`${baseUrl}/86`,
    },	  {
      "type": "input",
      "label": "市编号",
      "prop": "cityCode",
      editDisplay: false
    },	  {
      "type": "input",
      "label": "市名称",
      "prop": "city",
      search: true,
      rules: [{
        required: true,
        message: '请输入正确的省级名称',
        trigger: 'blur'
      },
      {validator: regionName, trigger: 'blur'}]
    },	  {
      "type": "input",
      "label": "区编号",
      "prop": "areaCode",
      editDisplay: false
    },	  {
      "type": "input",
      "label": "区名称",
      "prop": "area",
      search: true,
      rules: [{
        required: true,
        message: '请输入正确的省级名称',
        trigger: 'blur'
      },
      {validator: regionName, trigger: 'blur'}]
    },	  {
      "type": "input",
      "label": "详细地址",
      "prop": "address",
      rules: [{
        required: true,
        message: '请输入详细地址',
        trigger: 'blur'
      }]
    },	  {
      "type": "input",
      "label": "全地址",
      "prop": "fullAddress",
      editDisplay: false
    },	  {
      "type": "input",
      "label": "创建时间",
      "prop": "createTime",
    hide: true,
    editDisplay: false
    },	  {
      "type": "input",
      "label": "创建人",
      "prop": "createUser",
      editDisplay: false
    },	  {
      "type": "input",
      "label": "修改时间",
      hide: true,
      "prop": "updateTime",
      editDisplay: false
    },	  {
      "type": "input",
      "label": "修改人",
      "prop": "updateUser",
      hide: true,
      editDisplay: false
    }  ]


}
